from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution(object):
    def rotate(self, matrix):
        m,n = len(matrix),len(matrix[0])
        for i in range(m):
            for j in range(i,n):
                matrix[i][j],matrix[j][i] = matrix[j][i],matrix[i][j]
        for row in matrix:
            self.reverse(row)
        # 旋转每行
    def reverse(self, arr):
        i,j = 0,len(arr)-1
        while i<j:
            arr[i],arr[j] = arr[j],arr[i]
            i+=1
            j-=1
        
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    # your test code here